package teaching.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import teaching.mapper.HomeworkMapper;
import teaching.pojo.Homework;
import teaching.pojo.Submission;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Author:20201002983_郑雨蓓
 * Date: 2024/3/19
 * Description:
 */
@Service
public class HomeworkService extends ServiceImpl<HomeworkMapper, Homework> {
    @Resource
    private HomeworkMapper homeworkMapper;

    public List<Homework> listByCid(Long cid) {
        return homeworkMapper.getHomeworkByCid(cid);
    }

    public List<Homework> listStudentHomework(Long cid, Long sid) {
        System.out.println("cid=" + cid + "sid=" + sid);
        return homeworkMapper.listStudentHomework(cid, sid);
    }

    public int addHomework(Homework newHomework) {
        System.out.println("作业作业" + newHomework);
        return homeworkMapper.add(newHomework);
    }

    public int addSubmission(Submission submission) {
        return homeworkMapper.addSubmission(submission);
    }

    public List<Submission> getHomeworkSubmissions(long homeworkId) {
        return homeworkMapper.homeworkSubmission(homeworkId);
    }

    public int updateScore(Submission submission) {
        return homeworkMapper.updateSubmission(submission);
    }
}
